{
    "cells": [
        {
            "cell_type": "markdown",
            "id": "88141371-de4c-4c02-9e8f-10d2491b5a33",
            "metadata": {},
            "source": [
                "# Google Docs Demo\n",
                "Demonstrates our Google Docs data connector"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "id": "f6b62adf",
            "metadata": {},
            "outputs": [],
            "source": [
                "import logging\n",
                "import sys\n",
                "\n",
                "logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n",
                "logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "id": "fafc701d-5a10-4503-9dae-22698fb1aee9",
            "metadata": {},
            "outputs": [],
            "source": [
                "from llama_index import GPTListIndex, GoogleDocsReader\n",
                "from IPython.display import Markdown, display\n",
                "import os"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "id": "b8f0a9f2-c6a9-4840-a38a-0b2f8e433063",
            "metadata": {},
            "outputs": [],
            "source": [
                "# make sure credentials.json file exists\n",
                "document_ids = [\"<document_id>\"]\n",
                "documents = GoogleDocsReader().load_data(document_ids=document_ids)"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "id": "89ef1fac-aa36-4a5f-b5cf-bc4dfa0bd332",
            "metadata": {},
            "outputs": [],
            "source": [
                "index = GPTListIndex.from_documents(documents)"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "id": "c2c1573f-2e49-49e8-8daf-19e6f1777eaa",
            "metadata": {},
            "outputs": [],
            "source": [
                "# set Logging to DEBUG for more detailed outputs\n",
                "response = index.query(\"<query_text>\")"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "id": "6d4533c9-9020-4f50-837c-316ec2c454f2",
            "metadata": {},
            "outputs": [],
            "source": [
                "display(Markdown(f\"<b>{response}</b>\"))"
            ]
        }
    ],
    "metadata": {
        "kernelspec": {
            "display_name": "Python 3 (ipykernel)",
            "language": "python",
            "name": "python3"
        },
        "language_info": {
            "codemirror_mode": {
                "name": "ipython",
                "version": 3
            },
            "file_extension": ".py",
            "mimetype": "text/x-python",
            "name": "python",
            "nbconvert_exporter": "python",
            "pygments_lexer": "ipython3",
            "version": "3.11.1"
        }
    },
    "nbformat": 4,
    "nbformat_minor": 5
}